import {
  RouteRecordRaw,
  Router,
  RouterOptions,
  createRouter,
  createWebHistory,
} from "vue-router";
import { GabRoutes } from "./modules/Gab";
import { Vast } from "src/types/vast-system";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    component: () => import("src/layouts/Home.vue"),
    children: [
      GabRoutes,
      {
        path: "/Async",
        name: "Async",
        component: () => import("src/pioneers/Async/Async.vue"),
      },
      {
        path: "/Zhongxu",
        name: "Zhongxu",
        component: () => import("src/pioneers/Zhongxu/view/index.vue"),
      },
      {
        path: "/You",
        name: "You",
        component: () => import("src/pioneers/You/index"),
      },
    ],
  },
  {
    path: "/menu",
    name: 'menu',
    meta: { 
      menuName: '权限',
    },
    component: () => import("views/menu/menuConfig.vue")
  }
];
const options: RouterOptions = {
  history: createWebHistory(),
  routes,
};

const router: Router = createRouter(options);

router.beforeEach(async (to) => {
  const routeTitle = to.meta.title as string;
  if (routeTitle) {
    document.title = routeTitle;
  }else{
    document.title =  Vast.NAME
  }
});

export default router;
